Skip to content

Conversation

@erwango
Copy link
Member

@erwango erwango commented Nov 20, 2025

Currently, STM32 XSPI flash driver initialization aborts if application is run from external flash.
Though, constraints are actually different if:

  • application runs in XIP and is read from ext flash
  • application runs in RAM LOAD mode and is read from RAM, leaving the ext flash available for flash driver operations

Fix XSPI driver to allow flash operations in RAM LOAD.
Make necessary changes on N6 DK to be able to make use of it.

Once approved, it will have to be extended to O/QSPI drivers.
Then, we should also make sure this work using MSPI drivers.

Edit: Depends on mcu-tools/mcuboot#2547

@github-actions
Copy link

github-actions bot commented Nov 20, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
mcuboot mcu-tools/mcuboot@f3cc947 (v2.3.0-rc1) mcu-tools/mcuboot#2547 mcu-tools/mcuboot#2547/files

Additional metadata changed:

Name URL Submodules West cmds module.yml Blobs
mcuboot

DNM label due to: 1 project with PR revision and 1 project with metadata changes

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-mcuboot DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Nov 20, 2025
@erwango erwango force-pushed the fix_n6_flash_ext_app_upstream branch from 95dfb79 to 7eedd31 Compare November 20, 2025 10:09
Instantiate a `soc-nv-flash` compatible node to allow using XSPI flash
driver as a real flash controller on NOR device.

Signed-off-by: Erwan Gouriou <[email protected]>
@erwango erwango force-pushed the fix_n6_flash_ext_app_upstream branch from 5bab295 to c72d334 Compare November 24, 2025 15:58
@erwango erwango requested a review from etienne-lms November 24, 2025 16:05
spi-flash0 = &mx66uw1g45g;
zephyr,flash-controller = &mx66uw1g45g;
zephyr,flash = &mx66uw1g45g;
zephyr,flash = &ext_flash;
Copy link
Contributor

@JarmouniA JarmouniA Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a nit really, but ospi-nor-flash@0 node should not have the label mx66uw1g45g, rather something like ext_flash_controller, and consequently zephyr,flash-controller should be changed.

Comment on lines 2209 to 2211
/* Memory map could have been set by previous application */
/* Abort to allow following card oriented transactions */
/* If needed by the application, it will be re-enabled just after */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking suggestion as this a single inline comment.

Suggested change
/* Memory map could have been set by previous application */
/* Abort to allow following card oriented transactions */
/* If needed by the application, it will be re-enabled just after */
/* Memory map could have been set by previous application.
* If so, abort on-going operations to allow following card oriented transactions.
* If memory map mode is needed by the application, it will be re-enabled afterward.
*/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded, but in a different way.

Current driver protections prevent to initialize driver when run as from
an external application running from ext flash. Aim is to avoid performing
full driver initialization of the NOR flash controller the application
is read from.
But this problem is actually only valid when application is running in XIP
mode (read in memory mapped mode at run time).

In ram load mode, since there is no direct activity from the application
on the NOR device, nothing prevents the ext flash driver to be used fully.
Hence, we should allow the controller initialization to happen, with some
adjustments. Mostly, what we need is to:
- skip the hal init
- abort memory mapping afterwards to let the jedec reading happen.

Remove conditions around `stm32_xspi_is_memorymap()` and
`stm32_xspi_abort()` which can finally be useful in various cases.

Signed-off-by: Erwan Gouriou <[email protected]>
Point upstream mcuboot PR fixing stm32n6 fsbl variant configuration

Signed-off-by: Erwan Gouriou <[email protected]>
@erwango erwango force-pushed the fix_n6_flash_ext_app_upstream branch from c72d334 to 1ed8b00 Compare November 25, 2025 10:03
@sonarqubecloud
Copy link

Comment on lines +2196 to +2197
/* Memory-mapping could have been set by previous application */
/* Force HAL instance in correct state */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	/* Memory-mapping could have been set by previous application.
	 * Force HAL instance in correct state.
	 */

Comment on lines +2275 to +2277
/* Memory-mapping could have been set by previous application */
/* Abort to allow following Jedec transactions, it will be */
/* re-enabled afterwards if needed by the application. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	/* Memory-mapping could have been set by previous application.
	 * Abort to allow following Jedec transactions, it will be
	 * re-enabled afterwards if needed by the application.
	 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants